package com.lzq.model.bridge;

/**
 * @author : modify
 * @version : v1.0
 * @description :
 * @createTime : 2022/11/23 11:19
 * @updateUser : modify
 * @updateTime : 2022/11/23 11:19
 * @updateRemark :
 */
public interface VideoFile {
    /**
     * 解码
     *
     * @param fileName
     */
    void decode(String fileName);
}

class AviFile implements VideoFile {

    @Override
    public void decode(String fileName) {
        System.out.println("avi 视频格式 " + fileName);
    }
}

class RmvbFile implements VideoFile {

    @Override
    public void decode(String fileName) {
        System.out.println("rmvb 视频格式 " + fileName);
    }
}

abstract class OperatingSystemVersion {
    protected VideoFile videoFile;

    public OperatingSystemVersion(VideoFile videoFile) {
        this.videoFile = videoFile;
    }

    /**
     * 播放视频
     *
     * @param fileName
     */
    public abstract void play(String fileName);
}

class Windows extends OperatingSystemVersion {

    public Windows(VideoFile videoFile) {
        super(videoFile);
    }

    @Override
    public void play(String fileName) {
        videoFile.decode(fileName);
    }
}

class Mac extends OperatingSystemVersion {

    public Mac(VideoFile videoFile) {
        super(videoFile);
    }

    @Override
    public void play(String fileName) {
        videoFile.decode(fileName);
    }
}

class Test {
    public static void main(String[] args) {
        OperatingSystemVersion sys = new Mac(new AviFile());
        sys.play("肖申克的救赎");
    }
}